<?php
    /**
     * Export all member records in .xls format
     * with the help of the xlsHelper
     */

	//input the export file name
	$xls->setHeader('DSChiDoan_'.date('Y_m_d'));

    $xls->addXmlHeader();
    $xls->setWorkSheetName('DSChiDoan');

    //1st row for columns name
    $xls->openRow();
    $xls->writeString('Mã số');
    $xls->writeString('Tên');
    $xls->writeString('Trực thuộc vào');
    $xls->writeString('Sĩ số');
    $xls->writeString('Trạng thái');
    $xls->closeRow();

    //rows for data
    foreach ($unions as $model):
    	$xls->openRow();
	    $xls->writeString($model['Union']['id']);
	    $xls->writeString($model['Union']['union_name']);
	    $xls->writeString($model['ParentUnion']['union_name']);
	    $xls->writeString($model['Union']['number']);
	    if($model['Union']['active']==0) $xls->writeString('Ngừng hoạt động');
	    else $xls->writeString('Đang hoạt động');
	    $xls->closeRow();
    endforeach;

    $xls->addXmlFooter();
    exit();
?>
